<template>
	<view class="container">
		<load :ready="loading"></load>
		<view class="b-title">
			{{info.title}}
		</view>
		<view class="date flex-bt">
			<text>{{info.send_info.nickname}}</text>
			<text>{{info.created_at}}</text>
		</view>
		<u-parse :html="info.content" selectable></u-parse>
	</view>
</template>

<script>
	import { mapState, mapMutations, mapGetters } from 'vuex';
	import { messagesDetail} from '@/config/user/api';
	export default {
		data() {
			return {
				loading:true,
				id:'',
				content:'',
				info:'',
			}
		},
		components: {
		},
		onLoad(o) {
			if(o.id){
				this.id = o.id
			}
			this.getInfo();
		},
		
		computed: {
			...mapState({
			    userInfo: 'userInfo',
				addressMsg:'addressMsg',
				nowHospital:'nowHospital',
			})
		},
		methods: {	
			
			async getInfo(){
				const that = this;
				const res = await messagesDetail({id:that.id});
				that.loading = false;
				if (res.code != 1) {
					this.$common.showTip(res.msg,'none')
					return
				};
				that.info = res.data;
				uni.setNavigationBarTitle({
					title: res.data.title
				})
			},
			
			...mapMutations(['setUserInfo','setAddressMsg','setNowHospital'])
		}
	}
</script>

<style>
	page{
		background: #fff;
	}
</style>

<style scoped lang="scss">
	.b-title{
		text-align: center;
		padding: 30rpx;
		font-size: 32rpx;
		font-weight: bold;
	}
	.p{
		font-size: 26rpx;
	}
	.container{
		padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
	}
	.date{
		padding: 30rpx 0;
		font-size: 26rpx;
		color: #666;
		text{
			margin-right: 20rpx;
		}
	}
	
</style>